/**
 *
 *      ___                       ___
 *     /\  \          ___        /\  \
 *    /::\  \        /\  \      /::\  \
 *   /:/\:\  \       \:\  \    /:/\ \  \
 *  /:/  \:\  \      /::\__\  _\:\~\ \  \
 * /:/__/ \:\__\  __/:/\/__/ /\ \:\ \ \__\
 * \:\  \  \/__/ /\/:/  /    \:\ \:\ \/__/
 *  \:\  \       \::/__/      \:\ \:\__\
 *   \:\  \       \:\__\       \:\/:/  /
 *    \:\__\       \/__/        \::/  /
 *     \/__/                     \/__/
 *
 * CIS - Clang Indexing Service is a Project Manager & Source code indexing service
 * created so as to simplify the indexing of C/C++ based source code which use
 * standardized build mechanisms.
 *
 **/

#ifndef PROJECTDIRECTORY_HXX
#define	PROJECTDIRECTORY_HXX

#include "project.hxx"
#include "cisexception.hxx"

#include <Poco/SingletonHolder.h>
#include <Poco/HashMap.h>
#include <Poco/Mutex.h>

namespace cis {

class ProjectDirectory {
    typedef Project::ProjectPtr ProjectPtr;
    typedef Poco::HashMap<std::string, ProjectPtr> HashMap;
public:
    static ProjectDirectory& instance();

    bool hasProject(const std::string& name);

    ProjectPtr createProject(const std::string& name, const std::string& mf, const std::string& makeparams);

    ProjectPtr getProject(const std::string& name);

    void removeProject(const std::string& name);

private:

    ProjectPtr pCreateProject(const std::string& name, const std::string& mf, const std::string& makeparams);

    bool pHasProject(const std::string& name);

    ProjectDirectory(const ProjectDirectory& orig);

    ~ProjectDirectory() {
    }

    ProjectDirectory() {
    }

    friend class Poco::SingletonHolder<ProjectDirectory>;
    HashMap projMap;
    Poco::Mutex mtx;
};

}
#endif	/* PROJECTDIRECTORY_HXX */

